package com.jvm;

import java.util.ArrayList;

/**
 * 大对象挪到老年代的演示
 */
public class GCTest {

    // 添加运行JVM参数： -XX:+PrintGCDetails
    // 设置大对象大小 -XX:PretenureSizeThreshold=1000000 -XX:+UseSerialGC
    // vm: -XX:+PrintGCDetails -XX:PretenureSizeThreshold=1000000 -XX:+UseSerialGC
    public static void main(String[] args) throws InterruptedException {
        byte[] alllocation1 , alllocation2, alllocation3, alllocation4, alllocation5, alllocation6;
        alllocation1 = new byte[50000 * 1024];
        // alllocation2 = new byte[8000 * 1024];
        // alllocation3 = new byte[1000 * 1024];
        // alllocation4 = new byte[1000 * 1024];
        // alllocation5 = new byte[1000 * 1024];
        // alllocation6 = new byte[1000 * 1024];
        // Thread.sleep(Integer.MAX_VALUE);

    }
}

class queryUser{
    // ‐Xms1536M ‐Xmx1536M ‐Xmn512M ‐Xss256K ‐XX:SurvivorRatio=6 ‐XX:MetaspaceSize=256M ‐XX:MaxMetaspaceSize=256M ‐XX:+UseParNewGC ‐XX:+UseConcMarkSweepGC ‐XX:CMSInitiatingOccupancyFraction=75 ‐XX:+UseCMSInitiatingOccupancyOnly
    public static void main(String[] args) {
        ArrayList<User> userArrayList = new ArrayList<>();
        for (int i = 0; i < 5000; i++) {
            System.out.println("-----");
            userArrayList.add(new User(i,"xiaohu"));
        }
    }
}
